<?php
declare (strict_types=1);

namespace hiduoke\controller;

use think\App;
use think\facade\Cookie;


/**
 * 控制器基础类
 */
abstract class FrontendController extends BaseController
{
    protected $visit_type = 'index';

    protected $notLogin = '*';

    protected $notCheck = '*';

    /**
     * 构造方法
     * @access public
     * @param App $app 应用对象
     */
    public function __construct(App $app)
    {
        parent::__construct($app);
        $this->name = get_addon();
        $this->addon_path = $app->addons->getAddonsPath() . $this->name . DIRECTORY_SEPARATOR;
        $this->addon_config = "addon_{$this->name}_config";
        $this->addon_info = "addon_{$this->name}_info";
        $this->view->config([
            'view_path' => $this->addon_path . 'view' . DIRECTORY_SEPARATOR
        ]);

        // 如果有使用模板布局
        if ($this->layout) {
            $this->view->layout('layout/' . $this->layout);
        }
        Cookie::set("dk_plaid", (string)get_plaid());
        Cookie::set("dk_addon", $this->name);
    }

    public function getDkSys()
    {
        $dkSys = parent::getDkSys();
        $dkSys['project_type'] = 'addon';
        return $dkSys;
    }
}
